/*
 * ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
 * Without permission, no one has the right to obtain, disclose or use this software in any way.
 */
package com.ecarx.systemui.plugin.controller

import android.text.TextUtils


enum class WiFiPwdType {
    //加密方式
    /**
     *  ESS = 开放网络，不加密，无需密码
     */
    ESS,

    /**
     * WEP = 旧的加密方式，不推荐使用，仅需密码
     */
    WEP,

    /**
     * WAP  = 最常见的加密方式，仅需密码
     */
    WAP,

    /**
     * WPA2-EAP  = 企业加密方式，ID+密码验证
     */
    WPA2_EAP,
}
data class WifiData(
    val netId: Int,                 //WiFi网络id，只有已经保存密码的WiFi才有，用于重连网络
    val ssid: String,               //WiFi名称
    val rssi: Int,                  //WiFi信号强度 0到4  0信号最差 4信号最好
    val bssid: String?,             //WiFi地址
    val ipAddress: String?,         //ip地址(连接WiFi后才会有)
    val capabilities: WiFiPwdType,  //WiFi加密方式
    val isSavePwd: Boolean          //是否保存密码
)

interface IWifiItemData {
    fun getItemType() : Int
    fun isSaved(): Boolean
    fun getWifiData(): WifiData?
}

open class WifiItemTitlePreferred : IWifiItemData {
    override fun getItemType(): Int {
        return 0
    }

    override fun isSaved(): Boolean {
        return true
    }

    override fun getWifiData(): WifiData? {
        return null
    }

}

open class WifiItemTitleOther : WifiItemTitlePreferred() {
    override fun isSaved(): Boolean {
        return false
    }
}

open class WifiItemData(private var wifiData: WifiData?) : IWifiItemData {

    override fun getItemType(): Int {
        return 1
    }

    override fun isSaved(): Boolean {
        return wifiData?.isSavePwd == true
    }

    override fun getWifiData(): WifiData? {
        return wifiData
    }

    fun isMark() :Boolean {
        return !TextUtils.isEmpty(getWifiData()?.ipAddress)
    }
}

open class WifiItemNothing : WifiItemTitlePreferred() {
    override fun isSaved(): Boolean {
        return false
    }

    override fun getItemType(): Int {
        return 2
    }

}





